﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace Killboard.Controllers
{
    [HandleError]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            Models.KillRepository repo = new Killboard.Models.KillRepository();

            


            System.Globalization.CultureInfo myCI = new System.Globalization.CultureInfo("en-US");
            int week = myCI.Calendar.GetWeekOfYear(DateTime.Now.ToUniversalTime(), System.Globalization.CalendarWeekRule.FirstFourDayWeek,
                                                    System.DayOfWeek.Sunday);

            IEnumerable<Models.KillStats> killsByShip = repo.SumKillsByShip(week, DateTime.Now.Year);


            ViewData["killsByShip"] = killsByShip;


            var lastTwentyKills = repo.GetMostRecentKills(20);

            return View(lastTwentyKills);
        }

        public ActionResult About()
        {
            return View();
        }

        public ActionResult ShowKillsBytype(string shipType)
        {
            return View();
        }

        public ActionResult PilotStats()
        {
            Models.KillRepository repo = new Killboard.Models.KillRepository();
            return View(repo.GetTopKillersForWeek());
        }
    }
}
